#include<stdint.h>
//定义TSMP相关数据结构
// TSMP接收帧首部格式
struct Tsmp_rec_head
{
    uint8_t version;              // 版本号
    uint8_t type;                 // 类型
    uint8_t source_port;          // 源端口
    uint8_t reserve;              // 保留
    uint32_t local_time_sec;      // 本地时间秒时间戳
    uint32_t local_time_nanosec;  // 本地时间纳秒时间戳
    uint16_t ptcl_id;             // 协议标识
    uint16_t frame_id;            // 帧标识
    uint32_t global_time_sec;     // 全局时间秒时间戳
    uint32_t global_time_nanosec; // 全局时间纳秒时间戳
} __attribute__((packed));

// 接受数据帧负载
struct Read_data_rec_paylaod
{
    uint16_t data_n;
    uint16_t reserve;
    uint32_t addr;
    uint32_t data;
} __attribute__((packed));

// 封装接收帧负载
struct Pack_rec_payload
{
    uint8_t *ptp;
} __attribute__((packed));

// 响应接收帧负载
struct Resp_rec_payload
{
    uint8_t *ptp;
} __attribute__((packed));

struct Read_data_rec // 读数据接受帧
{
    struct Tsmp_rec_head head;            // head
    struct Read_data_rec_paylaod payload; // data
};

struct Pack_rec // 封装接收帧
{
    struct Tsmp_rec_head head;
    struct Pack_rec_payload payload; // data
};

struct Resp_rec // 响应接收帧
{
    struct Tsmp_rec_head head;
    struct Resp_rec_payload payload; //  data
};


int readDateRec();
struct Pack_rec packRec();
struct Resp_rec respRec();

int  packSend(uint8_t *ptp);
int readReqSend(uint32_t addr, uint16_t N);
int writeReqSend(uint32_t addr, uint32_t data);